﻿@using RuoVea.ExUtil;

@using Microsoft.Extensions.Options

@{
    ViewData["Title"] = "周期作业";
    string JobRootUrl = "";
    Layout = "";
}
<!DOCTYPE html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>@ViewData["Title"] - MES管理系统</title>
    <link href="/elementui/index.css" rel="stylesheet" />
    <link href="/elementui/index.extend.css?v=22" rel="stylesheet" />
    <style scoped>
        .extend .use {
            text-align: right;
            height: 60px;
            line-height: 60px;
            font-size: 14px
        }

        /*         .extend .use> img{
                            text-align: right;
                            line-height: 60px;
                                align-items: center;
                                display: flex;
                        } */
    </style>
</head>
<body>
    <div id="main" v-cloak>
        <el-extend-header 
                        logo-src="/img/logo.png"
                          logo-title="MES管理系统"
                          :menu-data="menuData" 
                        :active-index="activeIndex" 
                        user-name="百里东君" 
                        user-avatar="" 
                        login-out-txt="">
                        </el-extend-header>
        @*             <el-menu :default-active="activeIndex" mode="horizontal">
            <el-menu-item><div><img src="/img/logo.png" style="height:40px;" alt="订单管理系统"><span>订单管理系统</span></div></el-menu-item>
            <el-menu-item index="1"><a href="@("/"+JobRootUrl+"/dashboard")">周期作业</a></el-menu-item>
            <el-menu-item index="2"><a href="@("/"+JobRootUrl+"/log")">执行日志</a></el-menu-item>
            <el-menu-item index="3"><a href="@("/"+JobRootUrl+"/period")">作业分析</a></el-menu-item>
            <el-menu-item index="4"><a href="@("/"+JobRootUrl+"/setting")">设置</a></el-menu-item>
            <el-menu-item index="5"><a href="@("/"+JobRootUrl+"/info")">Info</a></el-menu-item>
            <el-header class="use">

            <el-dropdown>
            <span class="header-user" v-if="userName">{{ userName }}<img :src="userAvatar" style="height:40px" alt="avatar" v-if="userAvatar" /><i class="el-icon-setting" style="margin-left:10px;"></i></span>
            <slot></slot>
            <el-dropdown-menu>
            <el-dropdown-item icon="el-icon-close" v-on:click.native="Logout" v-if="loginOutTxt">{{loginOutTxt}}</el-dropdown-item>
            </el-dropdown-menu>
            </el-dropdown>

            </el-header>

            </el-menu> 
        </el-header>*@


        <el-main>
            <el-row type="flex" align="middle">
                <el-col :span="18">
                    <el-form :inline="true" :model="tableQuery.filter">
                        <el-form-item prop="jobName" label="任务名称">
                            <el-input v-model="tableQuery.filter.jobName" placeholder="任务名称" size="mini"></el-input>
                        </el-form-item>
                        <el-form-item prop="jobName" label="分组名称">
                            @* <el-input v-model="tableQuery.filter.jobGroup" placeholder="分组名称" size="mini"></el-input> *@
                            <el-select v-model="tableQuery.filter.jobGroup" clearable placeholder="请选择" size="mini">
                                <el-option key="default" label="默认" value="default"></el-option>
                                <el-option key="dev" label="开发区" value="dev"></el-option>
                                <el-option key="test" label="测试区" value="test"></el-option>
                                <el-option key="verify" label="验证区" value="verify"></el-option>
                                <el-option key="official" label="正式区" value="official"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item prop="jobName" label="启用/禁用">
                            <el-select v-model="tableQuery.filter.status" clearable placeholder="请选择" size="mini">
                                <el-option key="0" label="启用" value="0"></el-option>
                                <el-option key="1" label="禁用" value="1"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item prop="jobName">
                            <el-button type="primary" size="mini" v-on:click="OnLoadJobs">查询</el-button>
                        </el-form-item>
                    </el-form>
                </el-col>
                <el-col :span="5" style="text-align: right;">
                    <el-button type="primary" size="mini" icon="el-icon-plus" @@click="addDialogForm">新建任务</el-button>
                    <el-button type="default" size="mini" icon="el-icon-refresh" v-on:click="OnLoadJobs">刷新数据</el-button>
                </el-col>
            </el-row>
            <el-row type="flex" align="middle">
                <el-col :span="24" style="padding: 10px 0 0 0;">
                    <el-table ref="tb" :data="tableData" border stripe style="width: 100%;" size="mini" row-key="id" v-loading="loading">
                        <el-table-column type="expand" prop="index">
                            <template slot-scope="props">
                                <div style="padding:10px 15px;">
                                    <el-descriptions>
                                        <el-descriptions-item label="ID">{{ props.row.id }}</el-descriptions-item>
                                    </el-descriptions>
                                    <el-descriptions title="任务相关">
                                        <el-descriptions-item label="开始时间">{{ props.row.beginTime }}</el-descriptions-item>
                                        <el-descriptions-item label="结束时间">{{ props.row.endTime }}</el-descriptions-item>
                                        @*  <el-descriptions-item label="创建时间">{{ props.row.createTime }}</el-descriptions-item> *@
                                        @* <el-descriptions-item label="任务描述">{{ props.row.description }}</el-descriptions-item> *@
                                    </el-descriptions>
                                    <el-descriptions v-if="props.row.runType==0" :title="props.row.runTypeText">
                                        <el-descriptions-item label="程序集名称">{{ props.row.assemblyName }}</el-descriptions-item>
                                        <el-descriptions-item label="任务所在类">{{ props.row.className }}</el-descriptions-item>
                                    </el-descriptions>
                                    <el-descriptions v-else :title="props.row|scheduleTypeTitle">
                                        <el-descriptions-item label="请求地址">{{ props.row.requestUrl }}</el-descriptions-item>
                                        <el-descriptions-item label="Headers参数">{{ props.row.headers }}</el-descriptions-item>
                                        <el-descriptions-item label="请求参数">{{ props.row.parameters }}</el-descriptions-item>
                                    </el-descriptions>
                                    <el-descriptions title="通知">
                                        <el-descriptions-item label="邮件信息">{{ props.row.mailMsgTypeText }}</el-descriptions-item>
                                        <el-descriptions-item label="发送人">{{ props.row.sendMailers }}</el-descriptions-item>
                                    </el-descriptions>
                                    <el-descriptions title="机器人通知">
                                        <el-descriptions-item label="机器人信息">{{ props.row.horkMsgTypeText }}</el-descriptions-item>
                                        <el-descriptions-item label="机器人地址">{{ props.row.horkUrl }}</el-descriptions-item>
                                    </el-descriptions>
                                    <el-descriptions>
                                        <el-descriptions-item label="异常信息">{{ props.row.lastException }}</el-descriptions-item>
                                    </el-descriptions>
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column type="index" width="50" label="序号" align="center"></el-table-column>
                        <el-table-column prop="jobName" label="任务名称" min-width="120"></el-table-column>
                        <el-table-column prop="jobGroup" label="任务分组" width="105"></el-table-column>
                        <el-table-column prop="statusText" label="启动/禁用" width="80" align="center">
                            <template slot-scope="scope">
                                <el-tag size="mini" v-if="scope.row.status==0">{{scope.row.statusText}}</el-tag>
                                <el-tag size="mini" type="danger" v-else>{{scope.row.statusText}}</el-tag>
                            </template>
                        </el-table-column>

                        <el-table-column prop="triggerTypeText" label="触发器类型" align="center" width="90"></el-table-column>
                        <el-table-column prop="requestUrl" label="请求地址" min-width="220" :show-overflow-tooltip="true"></el-table-column>
                        <el-table-column prop="displayState" label="触发器状态" width="85" align="center"></el-table-column>

                        <el-table-column prop="intervalSecond" label="间隔时间/计划" width="120" align="center">
                            <template slot-scope="scope">
                                <el-tag size="mini" v-if="scope.row.triggerType==1">{{scope.row.cron}}</el-tag>
                                <el-tag size="mini" v-else>{{scope.row.intervalSecond}} 秒 </el-tag>
                            </template>
                        </el-table-column>
                        <el-table-column prop="lastException" label="最近异常" width="80" align="center">
                            <template slot-scope="scope">
                                <el-tag size="mini" type="danger" v-if="scope.row.hasLastException>0">异常</el-tag>
                            </template>
                        </el-table-column>
                        <el-table-column prop="createTime" label="创建时间" width="160"></el-table-column>
                        <el-table-column prop="description" label="任务描述" min-width="250"></el-table-column>
                        @* <el-table-column prop="runTimes" label="执行次数" align="center" width="160"></el-table-column> *@
                        <el-table-column prop="nextFireTime" label="下次执行时间" width="160"></el-table-column>
                        <el-table-column prop="previousFireTime" label="上次执行时间" width="160"></el-table-column>

                        <el-table-column width="60" label="操作">
                            <template slot-scope="scope">
                                <div v-if="scope.row.status==1">
                                    <el-tooltip content="删除任务" placement="bottom">
                                        <el-button type="danger" size="mini" icon="el-icon-delete-solid" v-on:click="handleDelete(scope.$index, scope.row)"></el-button>
                                    </el-tooltip>
                                </div>
                                <div v-else>
                                    <el-tooltip content="立即执行" placement="bottom">
                                        <el-button type="primary" size="mini" icon="el-icon-video-play" v-on:click="handleRun(scope.row.id)"></el-button>
                                    </el-tooltip>
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column fixed="right" width="190" label="操作">
                            <template slot-scope="scope">
                                <div v-if="scope.row.status==1">
                                    <el-tooltip content="开启任务" placement="bottom">
                                        <el-button type="warning" size="mini" icon="el-icon-open" v-on:click="handleStart(scope.row.id)"></el-button>
                                    </el-tooltip>
                                    <el-tooltip content="修改任务" placement="bottom">
                                        <el-button type="info" size="mini" icon="el-icon-edit" v-on:click="editDialogForm(scope.$index, scope.row)"></el-button>
                                    </el-tooltip>
                                    <el-tooltip content="执行日志" placement="bottom">
                                        <el-button type="success" size="mini" icon="el-icon-document" v-on:click="logDialog(scope.$index, scope.row)"></el-button>
                                    </el-tooltip>
                                </div>
                                <div v-else>
                                    <el-tooltip content="暂停任务" placement="bottom">
                                        <el-button type="info" size="mini" icon="el-icon-video-pause" v-on:click="handleStop(scope.row.id)"></el-button>
                                    </el-tooltip>
                                    <el-tooltip content="执行日志" placement="bottom">
                                        <el-button type="success" size="mini" icon="el-icon-document" v-on:click="logDialog(scope.$index, scope.row)"></el-button>
                                    </el-tooltip>
                                </div>
                            </template>
                        </el-table-column>

                    </el-table>
                    <el-pagination @@size-change="handleSizeChange" @@current-change="handleCurrentChange" :current-page="tableQuery.pageNo" :page-sizes="[10, 20, 30, 40, 50]" :page-size="tableQuery.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="tableQuery.totalRows"></el-pagination>
                </el-col>
            </el-row>
        </el-main>
        <el-dialog title="计划任务" :visible.sync="dialogFormVisible">

            <el-form :model="dialogForm" :rules="dialogRules" ref="dialogForm" size="small" label-width="8em">
                <el-row>
                    <el-col :span="12">
                        <el-form-item prop="jobName" label="任务名称">
                            <el-input v-model="dialogForm.jobName" autocomplete="off" placeholder="请输入内容"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item prop="jobGroup" label="任务分组">
                            <el-select v-model="dialogForm.jobGroup" placeholder="请选择任务分组">
                                <el-option key="default" label="默认" value="default"></el-option>
                                <el-option key="dev" label="开发区" value="dev"></el-option>
                                <el-option key="test" label="测试区" value="test"></el-option>
                                <el-option key="verify" label="验证区" value="verify"></el-option>
                                <el-option key="official" label="正式区" value="official"></el-option>
                            </el-select>
                            @* <el-input v-model="dialogForm.jobGroup" placeholder="请输入内容" autocomplete="off"></el-input> *@
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item prop="beginTime" label="开始日期">
                            <el-date-picker type="datetime" placeholder="开始日期" v-model="dialogForm.beginTime" style="width: 100%;"></el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item prop="endTime" label="结束时间">
                            <el-date-picker type="datetime" placeholder="结束时间" v-model="dialogForm.endTime" style="width: 100%;"></el-date-picker>
                        </el-form-item>
                    </el-col>



                    <el-col :span="12" v-if="dialogForm.triggerType==1">
                        <el-form-item prop="cron" label="Cron">
                            <el-input v-model="dialogForm.cron" placeholder="请输入内容" autocomplete="off"></el-input>
                        </el-form-item>
                    </el-col>

                    <el-col :span="6" v-if="dialogForm.triggerType==0">
                        <el-form-item prop="intervalSecond" label="执行间隔/秒" label-width="8em">
                            <el-input v-model.number="dialogForm.intervalSecond" placeholder="执行间隔时间，单位秒（如果有Cron，则IntervalSecond失效）" autocomplete="off"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6" v-if="dialogForm.triggerType==0">
                        <el-form-item prop="runTimes" label="执行次数" label-width="6em">
                            <el-input v-model.number="dialogForm.runTimes" placeholder="执行次数(默认无限循环)" autocomplete="off"></el-input>
                        </el-form-item>
                    </el-col>


                    <el-col :span="12" v-if="dialogForm.runType==0">
                        <el-form-item prop="assemblyName" label="执行程序集"> <el-input v-model="dialogForm.assemblyName" placeholder="请输入执行程序集" autocomplete="off"></el-input> </el-form-item>
                    </el-col>
                    <el-col :span="12" v-if="dialogForm.runType==0">
                        <el-form-item prop="className" label="任务所在类">
                            <el-input v-model="dialogForm.className" placeholder="请输入内容" autocomplete="off"></el-input>
                        </el-form-item>
                    </el-col>

                    <el-col :span="18" v-if="dialogForm.runType>0">
                        <el-form-item prop="requestUrl" label="请求url">
                            <el-input v-model="dialogForm.requestUrl" placeholder="请输入内容" autocomplete="off"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="18" v-if="dialogForm.runType>0">
                        <el-form-item prop="headers" label="Headers">
                            <el-input type="textarea" :rows="1" v-model="dialogForm.headers" placeholder="Headers(可以包含如：Authorization授权认证) 格式：{'Authorization':'userpassword..'}" autocomplete="off"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="18" v-if="dialogForm.runType==2||dialogForm.runType==3">
                        <el-form-item prop="parameters" label="Parameters"> <el-input type="textarea" :rows="1" v-model="dialogForm.parameters" placeholder="请求参数（Post，Put请求用）{' Authorization':'userpassword..'}" autocomplete="off"></el-input> </el-form-item>
                    </el-col>

                    <el-col :span="18">
                        <el-form-item prop="mailMsgType" label="邮件通知">
                            <el-select v-model="dialogForm.mailMsgType" placeholder="请选择邮件通知类型">
                                <el-option label="不通知" :value="parseInt(0)"></el-option>
                                <el-option label="错误时通知" :value="parseInt(1)"></el-option>
                                <el-option label="成功时通知" :value="parseInt(2)"></el-option>
                                <el-option label="所有情况通知" :value="parseInt(3)"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="18" v-if="dialogForm.mailMsgType>0">
                        <el-form-item prop="sendMailers" label="通知邮箱">
                            <el-input type="textarea" :rows="1" v-model="dialogForm.sendMailers" placeholder="请输入邮箱内容,多个邮箱请使用逗号隔开" autocomplete="off"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="18">
                        <el-form-item prop="horkMsgType" label="机器人通知">
                            <el-select v-model="dialogForm.horkMsgType" placeholder="请选择通知类型">
                                <el-option label="不通知" :value="parseInt(0)"></el-option>
                                <el-option label="错误时通知" :value="parseInt(1)"></el-option>
                                <el-option label="成功时通知" :value="parseInt(2)"></el-option>
                                <el-option label="所有情况通知" :value="parseInt(3)"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="18" v-if="dialogForm.horkMsgType>0">
                        <el-form-item prop="horkUrl" label="通知地址">
                            <el-input v-model="dialogForm.horkUrl" placeholder="请输入机器人地址" autocomplete="off"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="18">
                        <el-form-item prop="description" label="任务描述">
                            <el-input type="textarea" :rows="2" v-model="dialogForm.description"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @@click="dialogFormVisible = false">取 消</el-button>
                <el-button type="primary" @@click="submitForm">确 定</el-button>
            </div>

        </el-dialog>

    </div>

    <script type="text/javascript" src="/vue/vue.js?v=2.0"></script>
    <script type="text/javascript" src="/vue/vue-i18n.min.js?v=2.0"></script>
    <script type="text/javascript" src="/elementui/index.js"></script>
    <script type="text/javascript" src="/elementui/index.extend.js"></script>
    <script type="text/javascript" src="/vue/axios.min.js"></script>
    <script>
        Vue.component('ElExtendBody', {
            props: {
                logoSrc: String,
                logoTitle: String,
                activeIndex: { type: String, },
                menuData: Array,
                userName: String,
                userAvatar: String,
                loginOutTxt: String,
                handleLogout: Function,
            },
            template: `<el-header class="extend">
            <div class="header-wrapper el-menu-horizontal">
                <div class="header-left">
                    <el-menu :default-active="activeIndex" mode="horizontal">
                        <el-menu-item tabindex="-1">
                            <div><img v-bind:src="logoSrc" style="height:40px;margin-right:5px;" v-bind:alt="logoTitle"><span>{{logoTitle}}</span></div>
                        </el-menu-item>
                        <el-menu-item :index="item.path" :key="idx" v-for="(item,idx) in menuData"><a v-bind:href="item.path">{{item.title}}</a></el-menu-item>
                    </el-menu>
                </div>
                <div class="header-right">
                    <span class="header-user" v-if="userName">{{ userName }}</span>
                    <el-dropdown trigger="click" v-if="userName">
                        <span class="el-dropdown-link">
                            <img :src="userAvatar" style="height:40px;" alt="avatar" v-if="userAvatar" />
                            <i class="el-icon-arrow-down el-icon--right" v-if="loginOutTxt"></i>
                        </span>
                        <el-dropdown-menu>
                            <el-dropdown-item icon="el-icon-close" v-on:click.native="handleLogout" v-if="loginOutTxt">{{loginOutTxt}}</el-dropdown-item>
                            <slot></slot>
                        </el-dropdown-menu>
                    </el-dropdown>
                </div>
            </div></el-header>`
        });
        var $taskVue = new Vue({
            el: "#main",
            data() {
                return {
                    menuData: [
                        { title: "周期作业", path: "/dashboard" },
                        { title: "执行日志", path: "/log" },
                        { title: "作业分析", path: "/period" },
                        { title: "设置", path: "/setting" },
                        { title: "Info", path: "/Info" },
                    ],
                    activeIndex: "/dashboard",

               
                
                    tableData: [],
                    loading: false,
                    tableQuery: {
                        pageNo: 1,
                        pageSize: 10,
                        totalRows: 0,
                        filter: {
                            jobName: '',
                            jobGroup: "",
                            status: ""
                        }
                    },

                    dialogFormVisible: false,
                    dialogForm: { id: 0, schedName: '', jobName: '', jobGroup: 'default', beginTime: Date.parse('@(DateTime.Now.ToDateTimeString())'), endTime: Date.parse('@(DateTime.MaxValue.ToDateTimeString())'), cron: '', runTimes: 0, intervalSecond: 0, scheduleType: 0, triggerType: 0, runType: 1, triggerState: 0, requestUrl: '', headers: '', parameters: '', description: '', mailMsgType: 0, sendMailers: "", horkMsgType: 0, horkUrl: "", assemblyName: '', className: '' },
                    dialogInitForm: { id: 0, schedName: '', jobName: '', jobGroup: 'default', beginTime: Date.parse('@(DateTime.Now.ToDateTimeString())'), endTime: Date.parse('@(DateTime.MaxValue.ToDateTimeString())'), cron: '', runTimes: 0, intervalSecond: 0, scheduleType: 0, triggerType: 0, runType: 1, triggerState: 0, requestUrl: '', headers: '', parameters: '', description: '', mailMsgType: 0, sendMailers: "", horkMsgType: 0, horkUrl: "", assemblyName: '', className: '' },

                    dialogRules: {
                        jobName: [{ required: true, message: '请输入任务名称', trigger: 'blur' }, { min: 2, max: 50, message: '长度在 2 到 50 个字符', trigger: 'blur' }],
                        // jobGroup: [{ required: true, message: '请输入任务分组', trigger: 'blur' }, { min: 2, max: 50, message: '长度在 2 到 50 个字符', trigger: 'blur' }],
                        beginTime: [{ required: true, message: '请输入开始日期', trigger: 'change' }],
                        endTime: [{ required: true, message: '请输入结束时间', trigger: 'change' }],
                        cron: [{ required: true, message: '请输入Cron表达式', trigger: 'blur' }],
                        intervalSecond: [{ required: true, message: '请输入执行间隔/秒', trigger: 'blur' }, { type: 'number', message: '必须为数字值' }],
                        runTimes: [{ type: 'number', message: '必须为数字值' }],
                        requestUrl: [{ required: true, message: '请输入请求url', trigger: 'blur' }],
                        // headers: [{ required: true, message: '请输入Headers', trigger: 'blur' }],
                        // parameters: [{ required: true, message: '请输入Parameters', trigger: 'blur' }],
                        sendMailers: [{ required: true, message: '请输入通知邮箱', trigger: 'blur' }],
                        horkUrl: [{ required: true, message: '请输入机器人地址', trigger: 'blur' }],
                        assemblyName: [{ required: true, message: '请输入执行程序集', trigger: 'blur' }],
                        className: [{ required: true, message: '请输入任务所在类', trigger: 'blur' }],
                    },
                }
            },
            created() {
                setInterval(() => { this.OnLoadJobs(); }, 10000);
            },
            mounted: function () {
                // this.OnLoadJobs();
            },
            methods: {
                OnLoadJobs() {
                    var that = this;
                    that.loading = true;
                    axios.post("@("/jobList")", that.tableQuery)
                        .then(function (res) {
                            that.tableData = res.data.data.rows;
                            that.tableQuery.totalRows = res.data.data.totalRows;
                            that.loading = false;
                        }).catch(function (res) { that.loading = false; });
                },
                handleSizeChange(val) { var that = this; that.tableQuery.pageNo = 1; that.tableQuery.pageSize = val; that.OnLoadJobs(); },
                handleCurrentChange(val) { var that = this; that.tableQuery.pageNo = val; that.OnLoadJobs(); },

                addDialogForm() {
                    var that = this;
                    that.dialogFormVisible = true; that.dialogForm = null;
                    that.dialogForm = that.dialogInitForm;
                },
                editDialogForm(index, row) {
                    var that = this;
                    that.dialogFormVisible = true;
                    that.dialogForm = that.dialogInitForm;
                    axios("@("/" + JobRootUrl + "/getjob/")" + row.id).then(function (res) { if (res.data.code == 200) { that.dialogForm = res.data.data; } });
                },
                logDialog(index, row) { var that = this; window.location.href = "@("/" + JobRootUrl + "/log?id=")" + row.id; },
                submitForm() {
                    var that = this;
                    that.$refs["dialogForm"].validate((valid) => {
                        if (valid) {
                            axios.post("@("/" + JobRootUrl + "/jobsave")", that.dialogForm).then(function (res) {
                                if (res.data.code == 200) {
                                    ELEMENT.MessageBox.alert(res.data.message, "系统信息", { type: 'success', callback: () => { that.OnLoadJobs(); that.dialogForm = that.dialogInitForm; that.dialogFormVisible = false; } });
                                } else {
                                    ELEMENT.MessageBox.alert(res.data.message, "系统信息", { type: 'info', callback: () => { } });
                                }
                            });
                        }
                    });
                },
                handleStart(id) {
                    var that = this;
                    this.$confirm('确定开启此任务?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(() => {
                        axios("@("/" + JobRootUrl + "/start/")" + id).then(function (res) {
                            if (res.data.code == 200) {
                                that.$message({ message: res.data.message, center: true, type: 'success' });
                                that.OnLoadJobs();
                            } else {
                                that.$message({ message: res.data.message, center: true, type: 'error' });
                            }
                        });
                    });
                },
                handleStop(id) {
                    var that = this;
                    this.$confirm('确定暂停此任务?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(() => {
                        axios("@("/" + JobRootUrl + "/stop/")" + id).then(function (res) {
                            if (res.data.code == 200) {
                                that.$message({ message: res.data.message, center: true, type: 'success' });
                                that.OnLoadJobs();
                            } else {
                                that.$message({ message: res.data.message, center: true, type: 'error' });
                            }
                        });
                    });

                },
                handleRun(id) {
                    var that = this;
                    this.$confirm('确定运行此任务?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(() => {
                        axios("@("/" + JobRootUrl + "/run/")" + id).then(function (res) {
                            if (res.data.code == 200) {
                                that.$message({ message: res.data.message, center: true, type: 'success' });
                                that.OnLoadJobs();
                            } else {
                                that.$message({ message: res.data.message, center: true, type: 'error' });
                            }
                        });
                    });
                },
                handleDelete(index, row) {
                    var that = this;
                    this.$confirm('确定删除此任务?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(() => {
                        axios("@("/" + JobRootUrl + "/remove/")" + row.id).then(function (res) {
                            if (res.data.code == 200) {
                                that.$message({ message: res.data.message, center: true, type: 'success' });
                                rows.splice(index, 1);
                                that.OnLoadJobs();
                            } else {
                                that.$message({ message: res.data.message, center: true, type: 'error' });
                            }
                        });
                    });
                }
            },
            filters: {
                scheduleTypeTitle(data) {
                    return data.scheduleTypeText + ":" + data.runTypeText;
                }
            }
        });
    </script>
</body>
</>
